﻿<%@ Page Title="" Language="C#" MasterPageFile="Function.Master" AutoEventWireup="true" CodeBehind="AdministratorList.aspx.cs" Inherits="LEARNREN.COM.WebSite.Admin.AdministratorList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var dataTableInPage;

        $(document).ready(function () {
            dataTableInPage = showDataTable();
        });
        function showDataTable() {
            var dt = dataTableExt("AdministratorList.ashx", "dataTable",
                           [{ "sClass": "center", "mDataProp": "UserName", "width": 60 },
                           { "sClass": "center", "mDataProp": "Email" },
                           { "sClass": "center", "mDataProp": "Comment" },
                           { "sClass": "center", "mDataProp": "CreationDate", "width": 130 },
                           { "sClass": "center", "mDataProp": "LastActivityDate", "width": 130 },
                           { "sClass": "center", "mDataProp": "IsLockedOutStr", "width": 40 },
                           {
                               //自定义列
                               "mDataProp": "UserName",
                               "width": 180,
                               "sClass": "center",
                               "bSearchable": false,
                               "bStorable": false,
                               "bStateSave": true,
                               "mRender": function (obj, display, fullData) {
                                   var btnStr = fullData.IsLockedOut ? "解锁" : "锁定";
                                   return '<a href="#" class="inlineButton" onclick=\"switchLock(\'' + obj + '\',\'' + btnStr + '\');return false;\">' + btnStr + '</a>&nbsp;&nbsp;'
                                         + '<a href="#" class="inlineButton" onclick=\"showEditpannel(' + obj + ');return false;\">编辑</a>&nbsp;&nbsp;'
                                         + '<a href=\"#\" class="inlineButton" onclick=\"deleteUser(\'' + obj + '\');return false;\">删除</a>';
                               }
                           }]);
            return dt;
        }

        function switchLock(userName, oName) {
            if (confirm("确定要" + oName + "此管理员吗？")) {
                $.post("Administrator.ashx",
                   { o: 1, userName: userName },
                   function (data) {
                       if (!data) {
                           showDialog(oName + "失败！", "提示");
                       }
                       else {
                           if (data.result) {
                               showDialog(oName + "成功！", "提示");
                               if (dataTableInPage) {
                                   dataTableInPage.fnStandingRedraw();
                               }
                           }
                           else {
                               showDialog(oName + "失败！", "提示");
                           }
                       }
                   },
                   "json");
            }
            return false;
        }

        function showEditpannel(id, title) {
            showTab("tabs-editarticle" + id, title, "articleedit.aspx?action=Edit&id=" + id);
            return false;
        }
        
        function deleteUser(userName) {
            if (confirm("确定要删除此管理员吗？")) {
                $.post("Administrator.ashx",
                   { o: 0, userName: userName },
                   function (data) {
                       if (!data) {
                           showDialog("删除失败！", "提示");
                       }
                       else {
                           if (data.result) {
                               showDialog("删除成功！", "提示");
                               if (dataTableInPage) {
                                   dataTableInPage.fnStandingRedraw();
                               }
                           }
                           else {
                               showDialog("删除失败！", "提示");
                           }
                       }
                   },
                   "json");
            }
            return false;
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="dataTable" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>姓名</th>
                <th>邮件</th>
                <th>描述</th>
                <th>创建日期</th>
                <th>上次活动日期</th>
                <th>锁定</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>

    
</asp:Content>
